// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.audio.parameters;

import zombie.audio.FMODLocalParameter;
import zombie.core.math.PZMath;
import zombie.scripting.objects.VehicleScript;
import zombie.vehicles.BaseVehicle;

public class ParameterVehicleSteer extends FMODLocalParameter {
    private final BaseVehicle vehicle;

    public ParameterVehicleSteer(BaseVehicle _vehicle) {
        super("VehicleSteer");
        this.vehicle = _vehicle;
    }

    @Override
    public float calculateCurrentValue() {
        float _float = 0.0F;
        if (!this.vehicle.isEngineRunning()) {
            return _float;
        } else {
            VehicleScript vehicleScript = this.vehicle.getScript();
            if (vehicleScript == null) {
                return _float;
            } else {
                BaseVehicle.WheelInfo[] wheelInfo = this.vehicle.wheelInfo;
                int int0 = 0;

                for (int int1 = vehicleScript.getWheelCount(); int0 < int1; int0++) {
                    _float = PZMath.max(_float, Math.abs(wheelInfo[int0].steering));
                }

                return (float)((int)(PZMath.clamp(_float, 0.0F, 1.0F) * 100.0F)) / 100.0F;
            }
        }
    }
}
